package com.tyt.lelan.utils;

import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

public class AsycItemFreshLoder {

   private static final int UPDATE_ENTRY_OK=5;
	
	private static ExecutorService executorService = Executors.newFixedThreadPool(5); // 固定五个线程来执行任务
	private final static Handler handler = new Handler();
	
	public static void  rssRefresh(final String rssUrl,final Context context,final int rssid,final Date timeBase)
	{
		
		executorService.submit(new Runnable(){

			@Override
			public void run() {
				// TODO Auto-generated method stub
				
				try {
					new RssParser(rssUrl,context,timeBase,rssid).parser();
					
					Bundle data=new Bundle();
					data.putInt("id", rssid);
					Message msg=new Message();
					msg.what=UPDATE_ENTRY_OK;
					msg.setData(data);
					handler.sendMessage(msg);
					
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		
		});
	}
	
}
